package com.bdqn.crm.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bdqn.crm.pojo.CstService;
import com.bdqn.crm.service.CstServiceService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

@Controller
public class CstServiceController {

    @Resource
    private CstServiceService cstServiceService;

    @RequestMapping(value = "plan/list")
    public String list(Model model,String svrCustName, String svrDueTo, String svrTitle, Long pageIndex){

        //数据回显
        model.addAttribute("svrCustName",svrCustName);
        model.addAttribute("svrDueTo",svrDueTo);
        model.addAttribute("svrTitle",svrTitle);

        //如果为空，查询第一页
        if (pageIndex == null){
            pageIndex = 1L;
        }
        Page<CstService> page = new Page<>();
        page.setCurrent(pageIndex);
        IPage<CstService> cstServiceIPage = cstServiceService.page(svrCustName,svrDueTo,svrTitle,page);
        model.addAttribute("planPage",cstServiceIPage);
        return "plan/list";
    }
}
